<html xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" >  

    <ui:composition template="layout.xhtml">
        <ui:define name="corpo">
            <h:form id="buscar_form" acceptcharset="utf-8"> 
                <div id="breadcrumb">
                    <p:commandLink  actionListener="#{managerIndex.redirect('index.xhtml')}" value="Inicio" update="@form" immediate="true"/> >
                    <p:commandLink  actionListener="#{managerIndex.redirect('config.xhtml')}" value="Configurações" update="@form" immediate="true"/> >
                    <p:commandLink  actionListener="#{managerIndex.redirect('indexDistribuicao.xhtml')}" value="Distribuicao" update="@form" immediate="true"/> >
                    <p:commandLink  value="Pesquisar Distribuicao" update="@form" immediate="true"/>
                </div>
                <p:panel header="Pesquisar Distribuicao">
                    <p:messages showDetail="true"  id="msg" /> 

                    <h:panelGrid columns="2" id="panelGridEscolha" styleClass="textAlignRight"
                                 columnClasses="textAlignRight">
                        <h:outputLabel value="Recebedor: " />
                        <p:inputText  value="#{managerVisualizarDistribuicao.distribuicao.recebedor.nome}" size="34" />

                        <h:outputLabel value="Data : " />
                        <p:calendar value="#{managerVisualizarDistribuicao.distribuicao.dataDistribuicao}" mode="popup"
                                    showOn="both" 
                                    pattern="dd/MM/yyyy" size="30"/>
                    </h:panelGrid>
                    <div class="buttonAction">
                        <p:commandButton icon="ui-icon-search" value="Buscar" 
                                     actionListener="#{managerVisualizarDistribuicao.pesquisarDistribuicao()}" 
                                     update="@form, disTable, msg"/>
                        <p:commandButton value="Voltar" icon="ui-icon-arrowreturnthick-1-w" 
                                         actionListener="#{managerVisualizarDistribuicao.redirect('indexSelo.xhtml')}"
                                         immediate="true"/>
                    </div>
                    <p:dataTable id="disTable" var="d" value="#{managerVisualizarDistribuicao.lstPesquisarDis}" 
                                 paginator="true" rows="5"
                                 paginatorPosition="bottom"
                                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"  
                                 rowsPerPageTemplate="5,10,15">   >  

                        <f:facet name="header">  
                            Distribuições Realizadas
                        </f:facet>
                            
                        <p:column style="width:400px;">  
                            <f:facet name="header" >   
                                Executante
                            </f:facet>  
                            <h:outputText value="#{d.executante.nome}" style="font-weight: bold;"/>  
                        </p:column>
                        <p:column style="width:400px;">  
                            <f:facet name="header" >   
                                Recebedor
                            </f:facet>  
                            <h:outputText value="#{d.recebedor.nome}" style="font-weight: bold;"/>
                        </p:column>
                        <p:column style="width:200px;">  
                            <f:facet name="header" >   
                                Data 
                            </f:facet>  
                            <h:outputText value="#{d.dataDistribuicao}" style="font-weight: bold;">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss"/>
                            </h:outputText>
                                                 
                        </p:column>
                        <p:column style="width:80px;">  
                            <f:facet name="header">  
                                <h:outputText value="Opções" />   
                            </f:facet>
                            <p:commandButton  icon="editar" actionListener="#{managerEditarDistribuicao.redirect('editarDistribuicao.xhtml',d)}" update="@form"/> 
                            <p:commandButton  icon="view" actionListener="#{managerVisualizarDistribuicao.redirect('visualizarDistribuicao.xhtml', d)}" update="@form"/>   

                        </p:column>
                       </p:dataTable> 
                </p:panel>

            </h:form>
        </ui:define>
    </ui:composition>
</html>
